SOFcntl


C Specification

#include <dolphin/socket.h>

#define SO_F_GETFL     3
#define SO_F_SETFL     4

#define SO_O_NONBLOCK  0x04

int SOFcntl( int s, int cmd, ... );

Description

SOFcntl() performs the following operations on open socket descriptors.

Cmd Argument Type Description
SO_F_GETFL none   Get the socket descriptor flags.
SO_F_SETFL OR-ed SO_O_* flags int Set the socket descriptor flags.

To set the socket descriptor to non-blocking mode, use the following code:

val = SOFcntl(s, SO_F_GETFL, 0);
SOFcntl(s, SO_F_SETFL, val | SO_O_NONBLOCK);

To revert the socket descriptor to blocking mode, use the following code:

val = SOFcntl(s, SO_F_GETFL, 0);
SOFcntl(s, SO_F_SETFL, val & ~SO_O_NONBLOCK);

The socket descriptor is in blocking mode by default.

Arguments

s Socket descriptor.
cmd Command (SO_F_*).

Return Values

non-negative Succeeded.
SO_EBADF Bad socket descriptor.
SO_EINVAL Invalid operation.
SO_ENETRESET Socket library is not initialized.

Note: Additional errors may be generated and returned in future library releases. All the negative return values must be treated as generic errors.

See Also

SOAccept(), SOConnect(), SORecv() , SOSend()